#ifndef ADL_PIN_CONNECT_BLOCK_H_
#define ADL_PIN_CONNECT_BLOCK_H_

#define PINSEL_BASE_ADDR	0xE002C000
#define PINSEL0        (*(volatile U32 *)(PINSEL_BASE_ADDR + 0x00))
#define PINSEL1        (*(volatile U32 *)(PINSEL_BASE_ADDR + 0x04))
#define PINSEL2        (*(volatile U32 *)(PINSEL_BASE_ADDR + 0x08))
#define PINSEL3        (*(volatile U32 *)(PINSEL_BASE_ADDR + 0x0C))
#define PINSEL4        (*(volatile U32 *)(PINSEL_BASE_ADDR + 0x10))
#define PINSEL5        (*(volatile U32 *)(PINSEL_BASE_ADDR + 0x14))
#define PINSEL6        (*(volatile U32 *)(PINSEL_BASE_ADDR + 0x18))
#define PINSEL7        (*(volatile U32 *)(PINSEL_BASE_ADDR + 0x1C))
#define PINSEL8        (*(volatile U32 *)(PINSEL_BASE_ADDR + 0x20))
#define PINSEL9        (*(volatile U32 *)(PINSEL_BASE_ADDR + 0x24))
#define PINSEL10       (*(volatile U32 *)(PINSEL_BASE_ADDR + 0x28))

#define PINMODE0        (*(volatile U32 *)(PINSEL_BASE_ADDR + 0x40))
#define PINMODE1        (*(volatile U32 *)(PINSEL_BASE_ADDR + 0x44))
#define PINMODE2        (*(volatile U32 *)(PINSEL_BASE_ADDR + 0x48))
#define PINMODE3        (*(volatile U32 *)(PINSEL_BASE_ADDR + 0x4C))
#define PINMODE4        (*(volatile U32 *)(PINSEL_BASE_ADDR + 0x50))
#define PINMODE5        (*(volatile U32 *)(PINSEL_BASE_ADDR + 0x54))
#define PINMODE6        (*(volatile U32 *)(PINSEL_BASE_ADDR + 0x58))
#define PINMODE7        (*(volatile U32 *)(PINSEL_BASE_ADDR + 0x5C))
#define PINMODE8        (*(volatile U32 *)(PINSEL_BASE_ADDR + 0x60))
#define PINMODE9        (*(volatile U32 *)(PINSEL_BASE_ADDR + 0x64))


/// Pin 46 function selection ///////////////////////////////////////////////////

// GPIO Port 0.0
#define adl_pin_connect_block_CONFIG_GPIO_P0_0()	(PINSEL0 &= ~(0x03 << 0));\
													(PINSEL0 |= (0x00 << 0));
// CAN1 receiver input
#define adl_pin_connect_block_CONFIG_RD1()			(PINSEL0 &= ~(0x03 << 0));\
													(PINSEL0 |= (0x01 << 0));
// Transmitter output for UART3
#define adl_pin_connect_block_CONFIG_TXD3()			(PINSEL0 &= ~(0x03 << 0));\
													(PINSEL0 |= (0x02 << 0));
// I2C1 data input/output (this is not an open-drain pin)
#define adl_pin_connect_block_CONFIG_SDA1()			(PINSEL0 &= ~(0x03 << 0));\
													(PINSEL0 |= (0x03 << 0));
/////////////////////////////////////////////////////////////////////////////////

/// Pin 47 function selection ///////////////////////////////////////////////////

// GPIO Port 0.1
#define adl_pin_connect_block_CONFIG_GPIO_P0_1()	(PINSEL0 &= ~(0x03 << 2));\
													(PINSEL0 |= (0x00 << 2));
// CAN1 transmitter output
#define adl_pin_connect_block_CONFIG_TD1()			(PINSEL0 &= ~(0x03 << 2));\
													(PINSEL0 |= (0x01 << 2));
// Receiver input for UART3
#define adl_pin_connect_block_CONFIG_RXD3()			(PINSEL0 &= ~(0x03 << 2));\
													(PINSEL0 |= (0x02 << 2));
// I2C1 clock input/output (this is not an open-drain pin)
#define adl_pin_connect_block_CONFIG_SCL1()			(PINSEL0 &= ~(0x03 << 2));\
													(PINSEL0 |= (0x03 << 2));
/////////////////////////////////////////////////////////////////////////////////

/// Pin 98 function selection ///////////////////////////////////////////////////

// GPIO Port 0.2
#define adl_pin_connect_block_CONFIG_GPIO_P0_2()	(PINSEL0 &= ~(0x03 << 4));\
													(PINSEL0 |= (0x00 << 4));
// Transmitter output for UART0
#define adl_pin_connect_block_CONFIG_TXD0()			(PINSEL0 &= ~(0x03 << 4));\
													(PINSEL0 |= (0x01 << 4));
/////////////////////////////////////////////////////////////////////////////////

/// Pin 99 function selection ///////////////////////////////////////////////////

// GPIO Port 0.3
#define adl_pin_connect_block_CONFIG_GPIO_P0_3()	(PINSEL0 &= ~(0x03 << 6));\
													(PINSEL0 |= (0x00 << 6));
// Receiver input for UART0
#define adl_pin_connect_block_CONFIG_RXD0()			(PINSEL0 &= ~(0x03 << 6));\
													(PINSEL0 |= (0x01 << 6));
/////////////////////////////////////////////////////////////////////////////////

/// Pin 48 function selection ///////////////////////////////////////////////////

// GPIO Port 0.10
#define adl_pin_connect_block_CONFIG_GPIO_P0_10()	(PINSEL0 &= ~(0x03 << 20));\
													(PINSEL0 |= (0x00 << 20));
// Transmitter output for UART2
#define adl_pin_connect_block_CONFIG_TXD2()			(PINSEL0 &= ~(0x03 << 20));\
													(PINSEL0 |= (0x01 << 20));
// I2C2 data input/output (this is not an open-drain pin)
#define adl_pin_connect_block_CONFIG_SDA2()			(PINSEL0 &= ~(0x03 << 20));\
													(PINSEL0 |= (0x02 << 20));
// Match output for Timer 3, channel 0
#define adl_pin_connect_block_CONFIG_MAT3_0()		(PINSEL0 &= ~(0x03 << 20));\
													(PINSEL0 |= (0x03 << 20));
/////////////////////////////////////////////////////////////////////////////////

/// Pin 49 function selection ///////////////////////////////////////////////////

// GPIO Port 0.11
#define adl_pin_connect_block_CONFIG_GPIO_P0_11()	(PINSEL0 &= ~(0x03 << 22));\
													(PINSEL0 |= (0x00 << 22));
// Receiver input for UART2
#define adl_pin_connect_block_CONFIG_RXD2()			(PINSEL0 &= ~(0x03 << 22));\
													(PINSEL0 |= (0x01 << 22));
// I2C2 clock input/output (this is not an open-drain pin)
#define adl_pin_connect_block_CONFIG_SCL2()			(PINSEL0 &= ~(0x03 << 22));\
													(PINSEL0 |= (0x02 << 22));
// Match output for Timer 3, channel 1
#define adl_pin_connect_block_CONFIG_MAT3_1()		(PINSEL0 &= ~(0x03 << 22));\
													(PINSEL0 |= (0x03 << 22));
/////////////////////////////////////////////////////////////////////////////////

#endif /*ADL_PIN_CONNECT_BLOCK_H_*/
